package com.wafersystems.springbootdemo.feign.factory;

import com.wafersystems.springbootdemo.feign.RemoteAdminService;
import com.wafersystems.springbootdemo.feign.impl.RemoteAdminServiceFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * feign exception
 * @author tandk
 * @date 2019/3/1
 */
@Component
public class RemoteAdminServiceFallbackFactory implements FallbackFactory<RemoteAdminService> {

  @Override
  public RemoteAdminService create(Throwable throwable) {
    RemoteAdminServiceFallbackImpl remoteAdminServiceFallback = new RemoteAdminServiceFallbackImpl();
    remoteAdminServiceFallback.setCause(throwable);
    return remoteAdminServiceFallback;
  }
}
